package com.atguigu.gmail.manage.controller;

import com.alibaba.dubbo.config.annotation.Reference;
import com.atguigu.gmail.api.bean.PmsBaseAttrInfo;
import com.atguigu.gmail.api.bean.PmsBaseAttrValue;
import com.atguigu.gmail.api.bean.PmsBaseSaleAttr;
import com.atguigu.gmail.api.bean.PmsProductSaleAttr;
import com.atguigu.gmail.api.service.AttrService;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

@Controller
@CrossOrigin
public class AttrController {

    @Reference
    AttrService attrService;

    @RequestMapping("attrInfoList")
    @ResponseBody
    public List<PmsBaseAttrInfo> attrInfoList(String catalog3Id){
        List<PmsBaseAttrInfo> attrInfos = attrService.attrInfoList(catalog3Id);
        return attrInfos;

    }


    @RequestMapping("saveAttrInfo")
    @ResponseBody
    public String saveAttrInfo(@RequestBody PmsBaseAttrInfo pmsBaseAttrInfo){
        String success = attrService.saveAttrInfo(pmsBaseAttrInfo);
        return "success";

    }




    @RequestMapping("getAttrValueList")
    @ResponseBody
    public List<PmsBaseAttrValue> getAttrValueList(String attrId){
        List<PmsBaseAttrValue> pmsBaseAttrValues= attrService.getAttrValueList(attrId);

        return pmsBaseAttrValues;
    }


    @RequestMapping("baseSaleAttrList")
    @ResponseBody
    public List<PmsBaseSaleAttr> baseSaleAttrList(){
        List<PmsBaseSaleAttr> pmsBaseAttrValues= attrService.baseSaleAttrList();

        return pmsBaseAttrValues;
    }




    @RequestMapping("spuSaleAttrList")
    @ResponseBody
    public List<PmsProductSaleAttr> spuSaleAttrList(String spuId){
        List<PmsProductSaleAttr> pmsProductSaleAttrs= attrService.spuSaleAttrList(spuId);

        return pmsProductSaleAttrs;
    }

}
